﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace AncientEmpires_025_132
{
    public class PlayerNation : Nation
    {
        
        public PlayerNation(ContentManager content, Vector2 positionKing, Vector2 topleft, NationName nationName, TeamName teamName, int money, int maxCharacter)
        {
            NationName = nationName;
            TeamName = teamName;
            Money = money;
            UnitMaxCharacter = maxCharacter;
            MyTypeTeam = TypeNation.Player;
            CharacterOwner = new List<Character>();
            BuildingOwner = new List<Building>();
        }

        void KingOfCharacter_SetFirstPositionSkirmishCharacter(object sender, EventArgs e)
        {
            for(int k = 0; k < CharacterOwner.Count; k++)
            {
                for (int i = 0; i < BuildingOwner.Count; i++)
                {
                    if (BuildingOwner[i].MyNationName == CharacterOwner[k].MyNationName && BuildingOwner[i].MyBuildingName == BuildingName.Castle)
                    {
                        for (int j = 0; j < CharacterOwner[k].ListSprites.Count; j++)
                        {
                            CharacterOwner[k].ListSprites[j].TopLeft = BuildingOwner[i].ListSprites[0].TopLeft;
                        }
                    }
                }
                break;
            }
        }


        public override void Update(GameTime gameTime)
        {
            for (int i = 0; i < BuildingOwner.Count; i++)
            {
                BuildingOwner[i].Update(gameTime);
            }

            for (int i = 0; i < CharacterOwner.Count; i++)
            {
                CharacterOwner[i].Update(gameTime);
            }
            
            
        }
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            
            for (int i = 0; i < BuildingOwner.Count; i++)
            {
                BuildingOwner[i].Draw(gameTime, spriteBatch);
            }

            for (int i = 0; i < CharacterOwner.Count; i++)
            {
                CharacterOwner[i].Draw(gameTime, spriteBatch);
            }
            
            //base.Draw(gameTime, spriteBatch);
        }
    }
}
